package com.mtask.task.service.impl;

import com.mtask.common.dto.vo.NotificationVo;
import com.mtask.common.entity.task.EmailJob;
import com.mtask.common.entity.task.NotifyJob;
import com.mtask.common.utils.WebUtil;
import com.mtask.task.service.ActionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ActionServiceImpl implements ActionService {
    @Resource
    private QueueMessageSender sender;

    @Override
    public boolean callback(String url) {
        return WebUtil.visit(url);
    }

    @Override
    public boolean sendEmail(EmailJob emailJob) {
        return false;
    }

    @Override
    public boolean senNotify(NotifyJob notifyJob) {
        NotificationVo notificationVo = new NotificationVo();
        notificationVo.setContent(notifyJob.getContent());
        notificationVo.setContentType(notifyJob.getContentType());
        notificationVo.setInformMethod(notifyJob.getInformMethod());
        notificationVo.setReceiver(notifyJob.getReceiver());
        notificationVo.setSender(notifyJob.getSender());
        sender.send("item.test", notificationVo);
        return true;
    }

}
